package com.example.cinema.bindingdata;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.ObservableField;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.cinema.R;
import com.example.cinema.drawview.CircleVideoPlayer;

import java.util.List;

//用户帖子信息
public class UserCircleData{
    //头像显示
    @BindingAdapter("userimgurl")
    public static void imageurl(View view, String url){ //自定义View属性映射
        if(view != null)
        {
            RequestOptions options = new RequestOptions()
                    .placeholder(R.mipmap.defaut_img)
                    .error(R.mipmap.defaut_img)
                    .fallback(R.mipmap.defaut_img);
            Glide.with(view).load(url)
                    .apply(options)
                    .into((ImageView) view);
        }
    }
    //播放地址
    @BindingAdapter("circleplayuer")
    public static void playerUrl(View view,String url)
    {
        if(url!= null)
        {
            CircleVideoPlayer player = (CircleVideoPlayer) view;
            player.SetUrlPlayer(url);
        }
    }
    //封面图
    @BindingAdapter("coerurl")
    public static void Coverimg(View view,String url)
    {
        if(url!= null)
        {
            CircleVideoPlayer player = (CircleVideoPlayer) view;
            player.Setimageurl(url);
        }
    }




    public ObservableField<String> userimage = new ObservableField<>();//用户头像
    public ObservableField<String> username  = new ObservableField<>();//用户名称
    public ObservableField<String> usertime  = new ObservableField<>();//发布时间
    public ObservableField<String> usertitle = new ObservableField<>();//帖子标题
    public ObservableField<String> usermsg   = new ObservableField<>();//帖子内容
    public ObservableField<String> money = new ObservableField<>();//打赏金额
    public ObservableField<String> coverimg = new ObservableField<>();//封面图
    public ObservableField<String> gifpath = new ObservableField<>();//GIF动图播放链接
    public ObservableField<String> evaluate = new ObservableField<>();//评价数量
    public ObservableField<String> admire = new ObservableField<>();//点赞数


}
